package com.tencreat.mall.controller.app;

import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.controller.BaseController;
import com.tencreat.domain.mall.MallFeedback;
import com.tencreat.domain.mall.dto.MallFeedbackDTO;
import com.tencreat.service.mall.IMallFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

@Api(tags = "99-意见反馈api")
@RestController
@RequestMapping("/api/feedback")
public class MallFeedbackCotroller extends BaseController {
    @Autowired
    private IMallFeedbackService mallFeedbackService;


    /**
     *用户提交反馈
     * @Author wangbingcheng
     * @Date 2021年09月13日
     * @param
     * @Return
     */
    @PostMapping("/add")
    @ApiOperation(value = "用户提交反馈")
    public HttpResult<Boolean> orderInfo(@RequestBody MallFeedbackDTO mallFeedbackDTO) throws InvocationTargetException, IllegalAccessException {
        return mallFeedbackService.addFeedBack(mallFeedbackDTO, getLoginCheck());
    }

    /**
     *用户查看反馈记录
     * @Author wangbingcheng
     * @Date 2021年09月13日
     * @param
     * @Return
     */
    @PostMapping("/list")
    @ApiOperation(value = "用户查看反馈记录")
    public HttpResult<List<MallFeedback>> getListByUser(){
        return mallFeedbackService.getListByUser(getLoginCheck());
    }
}
